#!/usr/bin/env python3
"""
修复syncApi.ts文件中的API调用
"""

import re
from pathlib import Path

def fix_sync_api():
    """修复syncApi.ts文件"""
    
    sync_api_file = Path("frontend/src/services/syncApi.ts")
    
    if not sync_api_file.exists():
        print(f"文件不存在: {sync_api_file}")
        return False
    
    # 读取文件内容
    with open(sync_api_file, 'r', encoding='utf-8') as f:
        content = f.read()
    
    # 替换所有的apiRequest为api
    content = content.replace('apiRequest.', 'api.')
    
    # 替换所有的response.data为response.data.data
    content = re.sub(r'return response\.data;', 'return response.data.data;', content)
    
    # 写回文件
    with open(sync_api_file, 'w', encoding='utf-8') as f:
        f.write(content)
    
    print("✅ syncApi.ts 文件修复完成")
    return True

if __name__ == "__main__":
    fix_sync_api()
